﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Extension;
[AddComponentMenu("UI/SubjectiveRawImage")]
public class SubjectiveRawImage : RawImage
{
    [SerializeField]
    ControlSubject m_subject = new ControlSubject(false, typeof(string));
    public ControlSubject subject { get { return m_subject; } }
    protected override void Start()
    {
        base.Start();
        if (subject.hasValidResource<Texture>())
            texture = subject.resource as Texture;
    }

    void LateUpdate()
    {
        if (subject.hasUpdate)
            if (subject.hasValidResource<Texture>())
                texture = subject.resource as Texture;
    }
#if UNITY_EDITOR

    protected override void OnValidate()
    {
        base.OnValidate();
        if (subject.hasValidResource<Texture>())
            texture = subject.resource as Texture;
    }
#endif
}
